package gonat

import "fmt"

const (
	/// <summary>
	/// Transport Control Protocol
	/// </summary>
	Tcp int = 0
	/// <summary>
	/// Datagram Protocol
	/// </summary>
	Udp int = 1
)

const (
	InvalidArguments                   int = 402
	ActionFailed                       int = 501
	Unathorized                        int = 606
	SpecifiedArrayIndexInvalid         int = 713
	NoSuchEntryInArray                 int = 714
	WildCardNotPermittedInSourceIp     int = 715
	WildCardNotPermittedInExternalPort int = 716
	ConflictInMappingEntry             int = 718
	SamePortValuesRequired             int = 724
	OnlyPermanentLeasesSupported       int = 725
	RemoteHostOnlySupportsWildcard     int = 726
	ExternalPortOnlySupportsWildcard   int = 727
	NoPortMapsAvailable                int = 728
	ConflictWithOtherMechanisms        int = 729
	WildCardNotPermittedInIntPort      int = 732
)

// UPNP Service type:
const (
	URN_LANHostConfigManagement_1  = "urn:schemas-upnp-org:service:LANHostConfigManagement:1"
	URN_Layer3Forwarding_1         = "urn:schemas-upnp-org:service:Layer3Forwarding:1"
	URN_WANCableLinkConfig_1       = "urn:schemas-upnp-org:service:WANCableLinkConfig:1"
	URN_WANCommonInterfaceConfig_1 = "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"
	URN_WANDSLLinkConfig_1         = "urn:schemas-upnp-org:service:WANDSLLinkConfig:1"
	URN_WANEthernetLinkConfig_1    = "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1"
	URN_WANIPConnection_1          = "urn:schemas-upnp-org:service:WANIPConnection:1"
	URN_WANPOTSLinkConfig_1        = "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1"
	URN_WANPPPConnection_1         = "urn:schemas-upnp-org:service:WANPPPConnection:1"

	URN_DeviceProtection_1 = "urn:schemas-upnp-org:service:DeviceProtection:1"
	// URN_LANHostConfigManagement_1  = "urn:schemas-upnp-org:service:LANHostConfigManagement:1"
	// URN_Layer3Forwarding_1         = "urn:schemas-upnp-org:service:Layer3Forwarding:1"
	// URN_WANCableLinkConfig_1       = "urn:schemas-upnp-org:service:WANCableLinkConfig:1"
	// URN_WANCommonInterfaceConfig_1 = "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"
	// URN_WANDSLLinkConfig_1         = "urn:schemas-upnp-org:service:WANDSLLinkConfig:1"
	// URN_WANEthernetLinkConfig_1    = "urn:schemas-upnp-org:service:WANEthernetLinkConfig:1"
	// URN_WANIPConnection_1          = "urn:schemas-upnp-org:service:WANIPConnection:1"
	URN_WANIPConnection_2        = "urn:schemas-upnp-org:service:WANIPConnection:2"
	URN_WANIPv6FirewallControl_1 = "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1"
	// URN_WANPOTSLinkConfig_1        = "urn:schemas-upnp-org:service:WANPOTSLinkConfig:1"
	// URN_WANPPPConnection_1         = "urn:schemas-upnp-org:service:WANPPPConnection:1"
	URN_WANPPPConnection_2 = "urn:schemas-upnp-org:service:WANPPPConnection:2"
)

type ContextError struct {
	Context string
	Err     error
}

func ctxError(err error, msg string) ContextError {
	return ContextError{
		Context: msg,
		Err:     err,
	}
}

func ctxErrorf(err error, msg string, args ...interface{}) ContextError {
	return ContextError{
		Context: fmt.Sprintf(msg, args...),
		Err:     err,
	}
}

func (err ContextError) Error() string {
	return fmt.Sprintf("%s: %v", err.Context, err.Err)
}
